<h4>用户信息</h4>
<div>
  <table class='table table-bordered table-hover'>
    <thead>
      <tr>
        <th>姓名</th>
        <th>用户名</th>
        <th>邮件</th>
        <th>角色</th>
        <th>部门</th>      
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      <% @users.each do |user| %>
      <tr>        
        <td><%=user.name %></td>
        <td><%=user.login %></td>
        <td><%=user.email %></td>
        <td>
          <% user.groups.each do |group| %>
            <span class="label label-success"><%=group.name %></span>
          <% end %>
        </td>
        <td>
          <%=user.try(:department).try(:name) %>
        </td>
        <td>
          <a href="<%=edit_admins_account_path(user) %>">修改</a>
          <a href="<%=new_admins_account_path %>">新增</a>
          <%= link_to '删除',admins_group_path(user.id),:method => :delete,:data => {:confirm => '确认删除?'} %>
          <!-- <a href="javascript:void(0)" class='fa fa-times'></a> -->
        </td>
      </tr>
      <% end %>
    </tbody>
  </table>
</div>
<div class='row'>
  <div class='col-md-4 user_role'>
    <div class='head'>
      <h4>用户角色</h4>
      <button type="button" class="btn btn-primary btn-xs role_create" data-toggle="modal" data-target="#role_user_create">创建</button>
    </div>
    <table class='table table-bordered table-hover'>
      <thead>
        <tr>
          <th class='col-md-7'>名称</th>
          <th class='col-md-3'>操作</th>
        </tr>
      <thead>
      <tbody>
        <% if @groups.count > 0 %>
          <%= render :partial => "item", collection: @groups, as: :group %>
        <% else %>
          <tr class='no_data'>
            <td colspan='2'>暂无</td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
  <div class='col-md-8 user_permission'>
    <h4>角色权限</h4>
    <table class='table table-bordered'>
      <thead>
        <tr>
          <th>模块</th>
          <th>功能</th>
        </tr>
      <thead>
      <tbody>
        <tr class='no_data'>
          <td colspan='2'>暂无</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>

<div class="modal fade" id="role_user_create">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">
          <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
        </button>
        <h4 class="modal-title">创建角色</h4>
      </div>
      <div class="modal-body">
        <div class="alert alert-warning notify" role="alert"></div>
        <form role="form">
          <div class="form-group">
            <label>名称</label>
            <input type="text" name="group[name]" class="form-control name" placeholder="名称">
          </div>
          <div class="form-group">
            <%=render partial: "permission", locals: {permissions: @permissions, owner_permissions: []} %>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default cancel" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary save">保存</button>
      </div>
    </div>
  </div>
</div>